
// 121.买卖股票的最佳时机
class Solution {
public:
    int maxProfit(vector<int>& prices) {
        int n = prices.size();
        int prev = prices[0] , ret = 0;
        for(int i = 1;  i < n  ; i++)
        {
            ret = max(ret , prices[i] - prev);
            prev = min(prev , prices[i]);
        }
        return ret;
    }
};